//Organizational Leadership Variables

//Private Only Leadership Variable

generate pril=0
replace pril=1 if (rel==1 | rol==1) & !nl==1 & !al==1 & !gl==1 

//Public Only Leadership Variable

generate publ=0
replace publ=1 if (gl==1) & !rol==1 & !nl==1 & !al==1 & !rel==1 

//Civil Only Leadership Variable

generate civl=0
replace civl=1 if (al==1 | nl==1) & !rol==1 & !gl==1 & !rel==1

//Public Private Only Leadership Variable

generate ppl=0
replace ppl=1 if (gl==1 & (rel==1 | rol==1)) & !nl==1 & !al==1 

//Private Civil Only Leadership Variable

generate pricl=0
replace pricl=1 if ((rel==1 | rol==1) & (nl==1 | al==1)) & !gl==1 

//Public Civil Only Leadership Variable

generate pubcl=0
replace pubcl=1 if (gl==1 & (nl==1 | al==1)) & !rel==1 & !rol==1

//Private Private Civil Leadership Variable

generate ppcl=0
replace ppcl=1 if gl==1 & (nl==1 | al==1) & (rel==1 | rol==1)

//Hybrid Leadership Variable (More Than One Sector Involved in Leadership)

generate hybl=0
replace hybl=1 if pubcl==1 | pricl==1 | ppl==1 | ppcl==1

//No Leadership Variable

generate nol=0
replace nol=1 if rel==0 & rol==0 & gl==0 & nl==0 & al==0

// Public Leadership Footprint Index

generate publ2=0
replace publ2=1 if publ==1
replace publ2=.5 if ppl==1 | pubcl==1
replace publ2=.33 if ppcl==1

// Private Leadership Footprint Index

generate pril2=0
replace pril2=1 if pril==1
replace pril2=.5 if ppl==1 | pricl==1
replace pril2=.33 if ppcl==1

// Civil Leadership Footprint Index

generate civl2=0
replace civl2=1 if civl==1
replace civl2=.5 if pubcl==1 | pricl==1
replace civl2=.33 if ppcl==1

// Leadership Calculations

sum pril publ civl ppl pubcl pricl ppcl hybl nol
sum rel rol if pril==1


//Organizational Association (Authority Sharing) Variables -- combines involvement/design, association and partnership variables

//Private Only Associations Variable

generate pris=0
replace pris=1 if (roa==1 | ropar==1 | roinv==1 | rea==1 | repar==1 | reinv==1) & !ga==1 & !gpar==1 & !ginv==1 & !aa==1 & !apar==1 & !ainv==1 & !na==1 & !npar==1 & !ninv==1

//Public Only Associations Variable

generate pubs=0 
replace pubs=1 if (ga==1 | gpar==1 | ginv==1) & !roa==1 & !ropar==1 & !roinv==1 &!rea==1 &!repar==1 &!reinv==1 & !aa==1 & !apar==1 & !ainv==1 & !na==1 & !npar==1 & !ninv==1

//Civil Only Associations Variable

generate civs=0
replace civs=1 if (aa==1 | apar==1 | ainv==1 | na==1 | npar==1 | ninv==1) & !roa==1 & !ropar==1 & !roinv==1 &!rea==1 &!repar==1 &!reinv==1 & !ga==1 & !gpar==1 & !ginv==1 

//Private and Civil Only Associations Variable

generate prics=0
replace prics=1 if (roa==1 | ropar==1 | roinv==1 | rea==1 | repar==1 | reinv==1) & (aa==1 | apar==1 | ainv==1 | na==1 | npar==1 | ninv==1) & !ga==1 & !gpar==1 & !ginv==1 

//Public and Civil Only Associations Variable

generate pubcs=0
replace pubcs=1 if (aa==1 | apar==1 | ainv==1 | na==1 | npar==1 | ninv==1) & (ga==1 | gpar==1 | ginv==1) & !ropar==1 & !roa==1 & !roinv==1 & !rea==1 & !repar==1 & !reinv==1 

//Public and Private Only Associations Variable

generate pps=0
replace pps=1 if (roa==1 | ropar==1 | roinv==1 | rea==1 | repar==1 | reinv==1) & (ga==1 | gpar==1 | ginv==1) & !aa==1 & !apar==1 & !ainv==1 & !na==1 & !npar==1 & !ninv==1

//Public, Private and Civil Associations Variable

generate ppcs=0
replace ppcs=1 if (roa==1 | ropar==1 | roinv==1 | rea==1 | repar==1 | reinv==1) & (aa==1 | apar==1 | ainv==1 | na==1 | npar==1 | ninv==1) & (ga==1 | gpar==1 | ginv==1) 

//Retailer Associations Variable

generate res=0
replace res=1 if (rea==1 | repar==1 | reinv==1) 

//Supplier Associations Variable

generate ros=0
replace ros=1 if (roa==1 | ropar==1 | roinv==1) 

//Government Associations Variable

generate gs=0 
replace gs=1 if (ga==1 | gpar==1 | ginv==1) 

//Academic Associations Variable

generate as=0
replace as=1 if (aa==1 | apar==1 | ainv==1) 

//Non-Profit Associations Variable

generate ns=0
replace ns=1 if na==1 | npar==1 | ninv==1

//Hybrid Associations Variable

generate hybs=0
replace hybs=1 if pubcs==1 | prics==1 | pps==1 | ppcs==1

//No Associations Variable

generate nos=0
replace nos=1 if !roa==1 & !ropar==1 & !roinv==1 &!rea==1 &!repar==1 &!reinv==1 & !ga==1 & !gpar==1 & !ginv==1 & !aa==1 & !apar==1 & !ainv==1 & !na==1 & !npar==1 & !ninv==1 

// Public Associations Footprint Index

generate pubs2=0
replace pubs2=1 if pubs==1
replace pubs2=.5 if pps==1 | pubcs==1
replace pubs2=.33 if ppcs==1

// Private Associations Footprint Index

generate pris2=0
replace pris2=1 if pris==1
replace pris2=.5 if pps==1 | prics==1
replace pris2=.33 if ppcs==1

// Civil Associations Footprint Index

generate civs2=0
replace civs2=1 if civs==1
replace civs2=.5 if pubcs==1 | prics==1
replace civs2=.33 if ppcs==1

// Association Calculations

sum pris pubs civs pps pubcs prics ppcs hybs nos
sum res ros if pris==1


// Funding Variables

//Private Only Funding Variable

generate prifun=0
replace prifun=1 if (refun==1 | rofun==1) & !nfun==1 & !afun==1 & !gfun==1 

//Public Only Funding Variable

generate pubfun=0
replace pubfun=1 if (gfun==1) & !rofun==1 & !nfun==1 & !afun==1 & !refun==1 

//Civil Only Funding Variable

generate civfun=0 
replace civfun=1 if (afun==1 | nfun==1) & !rofun==1 & !gfun==1 & !refun==1

//Public and Private Only Funding Variable

generate ppfun=0
replace ppfun=1 if (gfun==1 & (refun==1 | rofun==1)) & !nfun==1 & !afun==1 

//Private and Civil Only Funding Variable

generate pricfun=0
replace pricfun=1 if ((refun==1 | rofun==1) & (nfun==1 | afun==1)) & !gfun==1 

//Public and Civil Only Funding Variable

generate pubcfun=0
replace pubcfun=1 if (gfun==1 & (nfun==1 | afun==1)) & !refun==1 & !rofun==1

//Public, Private and Civil Funding Variable

generate ppcfun=0
replace ppcfun=1 if gfun==1 & (nfun==1 | afun==1) & (refun==1 | rofun==1)

//Hybrid Funding Variable

generate hybfun=0
replace hybfun=1 if pubcfun==1 | pricfun==1 | ppfun==1 | ppcfun==1

//No Funding Variable

generate nofun=0
replace nofun=1 if !refun==1 & !rofun==1 & !nfun==1 & !afun==1 & !gfun==1
 
// Public Funding Footprint Index

generate pubfun2=0
replace pubfun2=1 if pubfun==1
replace pubfun2=.5 if ppfun==1 | pubcfun==1
replace pubfun2=.33 if ppcfun==1

// Private Funding Footprint Index

generate prifun2=0
replace prifun2=1 if prifun==1
replace prifun2=.5 if ppfun==1 | pricfun==1
replace prifun2=.33 if ppcfun==1

// Civil Funding Footprint Index

generate civfun2=0
replace civfun2=1 if civfun==1
replace civfun2=.5 if pubcfun==1 | pricfun==1
replace civfun2=.33 if ppcfun==1

// Funding Calculations

sum prifun pubfun civfun ppfun pubcfun pricfun ppcfun hybfun nofun
sum refun rofun if prifun==1


//Data Variables

//Private Only Data Variable

generate prid=0
replace prid=1 if (redat==1 | rodat==1) & !ndat==1 & !adat==1 & !gdat==1 

//Public Only Data Variable

generate pubd=0
replace pubd=1 if (gdat==1) & !rodat==1 & !ndat==1 & !adat==1 & !redat==1

//Civil Only Data Variable

generate civd=0
replace civd=1 if (adat==1 | ndat==1) & !rodat==1 & !gdat==1 & !redat==1

//Public and Private Only Data Variable

generate ppd=0
replace ppd=1 if (gdat==1 & (redat==1 | rodat==1)) & !ndat==1 & !adat==1 

//Private and Civil Only Data Variable

generate pricd=0
replace pricd=1 if ((redat==1 | rodat==1) & (ndat==1 | adat==1)) & !gdat==1 

//Public and Civil Only Data Variable

generate pubcd=0
replace pubcd=1 if (gdat==1 & (ndat==1 | adat==1)) & !redat==1 & !rodat==1

//Private, Private and Civil Data Variable

generate ppcd=0
replace ppcd=1 if gdat==1 & (ndat==1 | adat==1) & (redat==1 | rodat==1)

//Hybrid Data Variable

generate hybd=0
replace hybd=1 if pubcd==1 | pricd==1 | ppd==1 | ppcd==1

//No Data Variable

generate nod=0
replace nod=1 if redat==0 & rodat==0 & gdat==0 & ndat==0 & adat==0

// Public Data Footprint Index

generate pubd2=0
replace pubd2=1 if pubd==1
replace pubd2=.5 if ppd==1 | pubcd==1
replace pubd2=.33 if ppcd==1

// Private Data Footprint Index

generate prid2=0
replace prid2=1 if prid==1
replace prid2=.5 if ppd==1 | pricd==1
replace prid2=.33 if ppcd==1

// Civil Data Footprint Index

generate civd2=0
replace civd2=1 if civd==1
replace civd2=.5 if pubcd==1 | pricd==1
replace civd2=.33 if ppcd==1

// Data Calculations

sum prid pubd civd ppd pubcd pricd ppcd hybd nod
sum red rod if prid==1

  
//Use and Endorsement Variables

//Private Only Use and Endorsement Variable 

generate priu=0
replace priu=1 if (reuse==1 | rouse==1) & !nuse==1 & !ause==1 & !guse==1 

//Public Only Use and Endorsement Variable 

generate pubu=0
replace pubu=1 if (guse==1) & !rouse==1 & !nuse==1 & !ause==1 & !reuse==1

//Civil Only Use and Endorsement Variable 

generate civu=0
replace civu=1 if (ause==1 | nuse==1) & !rouse==1 & !guse==1 & !reuse==1

//Private and Public Only Use and Endorsement Variable 

generate ppu=0
replace ppu=1 if (guse==1 & (reuse==1 | rouse==1)) & !nuse==1 & !ause==1 

//Private and Civil Only Use and Endorsement Variable 

generate pricu=0
replace pricu=1 if ((reuse==1 | rouse==1) & (nuse==1 | ause==1)) & !guse==1 

//Public and Civil Only Use and Endorsement Variable 

generate pubcu=0
replace pubcu=1 if (guse==1 & (nuse==1 | ause==1)) & !reuse==1 & !rouse==1

//Private, Public and Civil Only Use and Endorsement Variable 

generate ppcu=0
replace ppcu=1 if guse==1 & (nuse==1 | ause==1) & (reuse==1 | rouse==1)

//Hybrid Use and Endorsement Variable 

generate hybu=0
replace hybu=1 if pubcu==1 | pricu==1 | ppu==1 | ppcu==1

//No Use and Endorsement Variable 

generate nou=0
replace nou=1 if reuse==0 & rouse==0 & guse==0 & nuse==0 & ause==0

// Public Use and Endorsement Footprint Index

generate pubu2=0
replace pubu2=1 if pubu==1
replace pubu2=.5 if ppu==1 | pubcu==1
replace pubu2=.33 if ppcu==1

// Private Use and Endorsement Footprint Index

generate priu2=0
replace priu2=1 if priu==1
replace priu2=.5 if ppu==1 | pricu==1
replace priu2=.33 if ppcu==1

// Civil Use and Endorsement Footprint Index

generate civu2=0
replace civu2=1 if civu==1
replace civu2=.5 if pubcu==1 | pricu==1
replace civu2=.33 if ppcu==1

// Use and Endorsement Calculations

sum priu pubu civu ppu pubcu pricu ppcu hybu nou
sum reu rou if priu==1



// Fingerprint Calculations

tabstat publ2 pril2 civl2 pubs2 pris2 civs2 prifun2 pubfun2 civfun2 pubd2 prid2 civd2 pubu2 priu2 civu2, stat(sum) columns(statistics)
//Divide each sum by 1225 to calculate the power fingerprint of each sector for each resource 



// General Variables 


//Intra-Resource Hybrid Variable

generate hyb=0
replace hyb=1 if hybl==1 | hybd==1 | hybfun==1 | hybu==1 | hybs==1

//Pure Public Variable (used to calculate inter-resource hybrid variable)

generate ppub=0
replace ppub=1 if (publ==1 | pubd==1 | pubfun==1 | pubu==1 | pubs==1) & !hybl==1 & !hybd==1 & !hybfun==1 & !hybu==1 & !hybs==1 & !civl==1 & !civd==1 & !civfun==1 & !civu==1 & !civs==1 & !pril==1 & !prid==1 & !prifun==1 & !priu==1 & !pris==1

//Pure Civil Variable (used to calculate inter-resource hybrid variable)

generate pciv=0
replace pciv=1 if (civl==1 | civd==1 | civfun==1 | civu==1 | civs==1) & !hybl==1 & !hybd==1 & !hybfun==1 & !hybu==1 & !hybs==1 & !publ==1 & !pubd==1 & !pubfun==1 & !pubu==1 & !pubs==1 & !pril==1 & !prid==1 & !prifun==1 & !priu==1 & !pris==1  

//Pure Private Variable (used to calculate inter-resource hybrid variable)

generate ppri=0
replace ppri=1 if (pril==1 | prid==1 | prifun==1 | priu==1 | pris==1) & !hybl==1 & !hybd==1 & !hybfun==1 & !hybu==1 & !hybs==1 & !publ==1 & !pubd==1 & !pubfun==1 & !pubu==1 & !pubs==1 & !civl==1 & !civd==1 & !civfun==1 & !civu==1 & !civs==1 

// Pure Unknown Variable (used to calculate inter-resource hybrid variable)

generate pno=0
replace pno=1 if nol==1 & nos==1 & nod==1 & nofun==1 & nou==1

//Any Public Variable 

generate pub=0
replace pub=1 if publ==1 | pubd==1 | pubfun==1 | pubu==1 | pubs==1

//Any Civil Variable 

generate civ=0
replace civ=1 if civl==1 | civd==1 | civfun==1 | civu==1 | civs==1

//Any Private Variable 

generate pri=0
replace pri=1 if pril==1 | prid==1 | prifun==1 | priu==1 | pris==1

//Any Public-Civil Variable 

generate pubc=0
replace pubc=1 if pubcl==1 | pubcd==1 | pubcfun==1 | pubcu==1 | pubcs==1

//Any Private-Civil Variable 

generate pric=0
replace pric=1 if pricl==1 | pricd==1 | pricfun==1 | pricu==1 | prics==1

//Any Public-Private Variable 

generate pp=0
replace pp=1 if ppl==1 | ppd==1 | ppfun==1 | ppu==1 | pps==1

//Any Public-Private-Civil Variable 

generate ppc=0
replace ppc=1 if ppcl==1 | ppcd==1 | ppcfun==1 | ppcu==1 | ppcs==1

//Any Unknown Variable 

generate no=0
replace no=1 if nol==1 | nos==1 | nod==1 | nofun==1 | nou==1

//Inter-Resource Hybrid Variable 

generate hybc=0
replace hybc=1 if !ppub==1 & !ppri==1 & !pciv==1 & !pno==1 & !hyb==1

//Sectoral Power Calculations

sum rel rol res ros red rod refun rofun reu rou

//Hybridity Calculations

sum hyb hybc 
sum hybl hybs hybfun hybd hybu hybc
sum pubc pric pp ppc
sum ppub pciv ppri

//Opacity Calculations

sum nol nos nofun nod nou pno no
list case if no==0

//Figure 2

#delimit ;
graph hbar (sum) publ (sum) civl (sum) pril (sum) pubcl (sum) ppl (sum) pricl (sum) ppcl, 
	showyvars yvaroptions(relabel(1 "Public" 2 "Civil" 3 "Private" 4 "Public/Civil" 5 "Public/Private" 6 "Private/Civil" 7 "Pub/Pri/Civ")) 
	blabel(bar) 
	ylabel(20 40 60 80 100, labels ticks tposition(outside)) 
	title(A: Organizational Leadership by Sector)
	legend(off)
	scheme(lean2)
	saving(lead, replace);
graph hbar (sum) pubs (sum) civs (sum) pris (sum) pubcs (sum) pps (sum) prics (sum) ppcs, 
	showyvars yvaroptions(relabel(1 "Public" 2 "Civil" 3 "Private" 4 "Public/Civil" 5 "Public/Private" 6 "Private/Civil" 7 "Pub/Pri/Civ")) 
	blabel(bar) 
	ylabel(20 40 60 80 100, labels ticks tposition(outside)) title(B: Organizational Assocations by Sector)
	legend(off)
	scheme(lean2)
	saving(assn, replace);
graph hbar (sum) pubfun (sum) civfun (sum) prifun (sum) pubcfun (sum) ppfun (sum) pricfun (sum) ppcfun, 
	showyvars yvaroptions(relabel(1 "Public" 2 "Civil" 3 "Private" 4 "Public/Civil" 5 "Public/Private" 6 "Private/Civil" 7 "Pub/Pri/Civ")) 
	blabel(bar) 
	ylabel(20 40 60 80 100, labels ticks tposition(outside)) title(C: Organizational Funding by Sector)
	legend(off)
	scheme(lean2)
	saving(fund, replace);
graph hbar (sum) pubd (sum) civd (sum) prid (sum) pubcd (sum) ppd (sum) pricd (sum) ppcd, 
	showyvars yvaroptions(relabel(1 "Public" 2 "Civil" 3 "Private" 4 "Public/Civil" 5 "Public/Private" 6 "Private/Civil" 7 "Pub/Pri/Civ")) 
	blabel(bar) 
	ylabel(20 40 60 80 100, labels ticks tposition(outside)) title(D: Data Sources by Sector)
	legend(off)
	scheme(lean2)
	saving(data, replace);
graph hbar (sum) pubu (sum) civu (sum) priu (sum) pubcu (sum) ppu (sum) pricu (sum) ppcu, 
	showyvars yvaroptions(relabel(1 "Public" 2 "Civil" 3 "Private" 4 "Public/Civil" 5 "Public/Private" 6 "Private/Civil" 7 "Pub/Pri/Civ")) 
	blabel(bar) 
	ylabel(20 40 60 80 100, labels ticks tposition(outside)) title(E: Use and Endorsement by Sector)
	legend(off)
	scheme(lean2)
	saving(use, replace);
gr combine "lead" "assn" "fund" "data" "use", col(1) iscale(.6) ysize(9) xsize(6.5) imargin(0 0 0 1) scheme(lean2) b1title("# of Cases", position(6) ring(4) size(vsmall));

